@extends('layouts.header')
@section('content')
<nav class="breadcrumb">
    <i class="Hui-iconfont">&#xe67f;</i> 首页 <span class="c-gray en">&gt;</span> 检测业务 <span class="c-gray en">&gt;</span>
    下载报告
    <a class="btn btn-primary radius r" style="line-height:1.6em;margin-top:3px"
       href="javascript:location.replace(location.href);" title="刷新"><i class="Hui-iconfont">&#xe68f;</i></a>
</nav>
<div class="page-container">
    <table class="table table-border table-bordered table-hover table-bg table-responsive" id="datatable">
        <thead>
        {{-- <tr>
            <th scope="col" colspan="6">合同管理</th>
        </tr> --}}
        <tr class="text-c">
            <th>批次编号</th>
            <th>客户名称</th>
            <th>受理人</th>
            <th>受理时间</th>
            <th>完成期限</th>
            <th>批准时间</th>
            <th>批次状态</th>
            <th>样品总量</th>
            <th>操作</th>
        </tr>
        </thead>
        <tbody>
        @foreach ($data as $val)
            <tr class="text-c">
                <td>{{ $val->batchNum }}</td>
                <td>{{ $val->client_name }}</td>
                <td>{{ $val->creator }}</td>
                <td>{{ $val->created_at }}</td>
                <td>{{ $val->deadline }}</td>
                <td>{{ $val->approve_end }}</td>
                <td>
                    @if ($val->status==5)
                        <span class="badge badge-primary radius">试验中</span>
                    @elseif ($val->status==8)
                        <span class="badge badge-primary radius">待审核</span>
                    @elseif ($val->status==11)
                        <span class="badge badge-default radius">审核完成</span>
                    @elseif ($val->status==13)
                        <span class="badge badge-danger radius">批准驳回</span>
                    @elseif ($val->status==14)
                        <span class="badge badge-success radius">批准通过</span>
                    @elseif ($val->status==17)
                        <span class="badge badge-success radius">待退样</span>
                    @else
                        <span class="badge badge-danger radius">未知</span>
                    @endif
                </td>
                <td>{{ $val->sum_count }}</td>
                <td>
                    <a class="btn btn-primary radius size-MINI" href="javascript:;" onclick="download_report({{ $val->id }},0)"><i class="Hui-iconfont">&#xe640;</i>检测报告</a>
                    <a class="btn btn-primary radius size-MINI" href="javascript:;" onclick="download_report({{ $val->id }},1)"><i class="Hui-iconfont">&#xe640;</i>刷新报告</a>
                    <a class="ml-5 btn btn-primary radius size-MINI" href="javascript:;" onclick="download_original({{ $val->id }})"><i class="Hui-iconfont">&#xe640;</i>原始记录</a>
                </td>
            </tr>
        @endforeach

        </tbody>
    </table>
</div>

<!--请在下方写此页面业务相关的脚本-->
<script type="text/javascript">
    $.fn.dataTable.ext.errMode = 'throw';//datatable抛异常的方式，在console中输出，默认以alert的方式弹出
    table = $('#datatable').DataTable({
        order: [[ 0, 'desc' ]],//默认第几个排序
        // ordering: false, // 是否排序
        "pageLength": 10,
        // "dom": '<"toolbar f-l pb-15">frtip',
        // "lengthChange": false,
        // "stateSave": true,// 状态保存 - 再次加载页面时还原表格状态
        // "stateDuration": -1,//仅保留当前会话的数据
        // "paging":false, //禁用分页
        serverSide: false,//服务器端处理模式——此模式下如：过滤、分页、排序的处理都放在服务器端进行。
        // responsive: true,//响应式，需要插件
        // fixedHeader: true,//表头固定，需要插件
        // autoWidth: false,
        ajax: "",
        processing: true,//加载数据时候是否显示进度条
        language: {url: '/admin/lib/datatables/dataTables_Chinese_Lang.json'}
    });

    /*下载原始记录*/
    function download_original(id) {
        window.open('/{{config('constant.name_admin')}}/exportReport/origin?contract_id=' + id, '_blank');
    }

    /* 跳转页面 */
    function jump_page(url, id) {
        location.href = url + '?id=' + id;
    }

    /*下载报告*/
    function download_report(id,is_new=0) {
        window.open('/{{config('constant.name_admin')}}/exportReport/export?id=' + id +'&new='+is_new, '_blank');
    }
</script>
@endsection